import QtQuick 2.15
import QtQuick.Controls 2.15

Item {
    id: newUser
    visible: false
    width: 320
    height: 160

    property string remarkStr: ""
    property string nameStr: ""
    property string ipStr: ""
    property string passwdStr: ""

    signal confirm()


    Rectangle {
        id: rectangle
        anchors.fill: parent
        color: "#FFFFE0"

        property real textWeigh: newUser.width
        property real textHeight: newUser.height / 5

        // 列
        Column {
            TextField {
                id: remark
                width: rectangle.textWeigh
                height: rectangle.textHeight

                placeholderText: "remark"
            }
            TextField {
                id: name
                width: rectangle.textWeigh
                height: rectangle.textHeight

                placeholderText: "name"
            }
            TextField {
                id: ip
                width: rectangle.textWeigh
                height: rectangle.textHeight

                placeholderText: "ip"
            }
            TextField {
                id: passwd
                width: rectangle.textWeigh
                height: rectangle.textHeight

                placeholderText: "passwd"
            }

        }

        // 行
        Row {
            y:rectangle.textHeight * 4

            Button {
                id:button1
                text: "确认"
                width: rectangle.textWeigh/2
                height: rectangle.textHeight

                onClicked: {
                    newUser.remarkStr = remark.text
                    newUser.nameStr = name.text
                    newUser.ipStr = ip.text
                    newUser.passwdStr = passwd.text
                    newUser.visible = false

                    confirm()
                }
            }

            Button {
                id:button2
                text: "取消"
                width: rectangle.textWeigh/2
                height: rectangle.textHeight

                onClicked: {
                    newUser.visible = false
                }
            }
        }
    }
}
